package mx.com.crowdgine.assetloader;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.List;

import junit.framework.Assert;

import org.junit.Test;

public class ObjLoaderTest {

	@Test
	public void testParse() throws Exception {
		ObjLoader objLoader = new ObjLoader();
		BufferedReader br = new BufferedReader(new FileReader("Assets/Models/casual01THP.obj"));
		objLoader.readModel(br);
		
		List<Vertex> vertices = objLoader.getVerts();
		List<Face> faces = objLoader.getFaces();
		
		Assert.assertEquals(-0.89944f, vertices.get(0).getVertexData().getX());
		Assert.assertEquals(1.36466f, vertices.get(0).getVertexData().getY());
		Assert.assertEquals(-0.04120f, vertices.get(0).getVertexData().getZ());
		
		Assert.assertEquals(-0.00216f, faces.get(0).getVertex(0).getVertexData().getX());
		Assert.assertEquals(0.83689f, faces.get(0).getVertex(0).getVertexData().getY());
		Assert.assertEquals(-0.09496f, faces.get(0).getVertex(0).getVertexData().getZ());
		
		Assert.assertEquals(0.96638f, faces.get(0).getTexCoordinate(0).getTexCoordData().getX());
		Assert.assertEquals(0.33270f, faces.get(0).getTexCoordinate(0).getTexCoordData().getY());
		
		Assert.assertEquals(-0.27445f, faces.get(0).getNormal(0).getNormalData().getX());
		Assert.assertEquals(0.84360f, faces.get(0).getNormal(0).getNormalData().getY());
		Assert.assertEquals(0.46153f, faces.get(0).getNormal(0).getNormalData().getZ());
		
	}
	
}
